<template>
  <div class="daigoubox">
    <div class="kuang" style="margin-top:20px;">
      <div>商品名称：</div>
      <input type="text" placeholder="必填" v-model="input1">
    </div>
    <div class="kuang">
      <div>生产企业：</div>
      <input type="text" v-model="input2">
    </div>
    <div class="kuang">
      <div>您的姓名：</div>
      <input type="text" v-model="input3">
    </div>
    <div class="kuang">
      <div>联系方式：</div>
      <input type="text" placeholder="必填" v-model="input4">
    </div>
    <div class="kuang">
      <div>您的地址：</div>
      <input type="text" v-model="input5">
    </div>
    <div class="kuang">
      <div>其他描述：</div>
      <input type="text" v-model="input6">
    </div>
    <div class="tijiao" @click="tijiao">提交</div>
  </div>
</template>

<script>

export default {
  name: "daigou",
  data() {
    return {
      input1:'',
      input2:'',
      input3:'',
      input4:'',
      input5:'',
      input6:''
    };
  },

  methods: {

    tijiao(){
      if(this.input1==''){
        this.$toast('商品名称不能为空');
        return
      }

      if(this.input4==''){
        this.$toast('手机号码不能为空');
        return
      }
      // if(this.input2==''){
      //   this.$toast('生产企业不能为空');
      //   return
      // }
      // if(this.input3==''){
      //   this.$toast('您的姓名不能为空');
      //   return
      // }
      if(!(/^1[3456789]\d{9}$/.test(this.input4))){ 
        this.$toast("手机号码有误，请重填");  
        return 
      } 
      // if(this.input5==''){
      //   this.$toast('您的地址不能为空');
      //   return
      // }
      // if(this.input6==''){
      //   this.$toast('其他描述不能为空');
      //   return
      // }
      this.$axios({
            method: "post",
            url: "/api/gzh_index.php?action=user_daigou",
            data:this.$qs.stringify({
              goods_name:this.input1,
              suppliers_name:this.input2,
              user_name:this.input3,
              phone:this.input4,
              address:this.input5,
              keywords:this.input6,
            }),
            headers: {                                                                                            
                'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8'
            },
        })
        .then(response => {
            console.log(response.data)
            if(response.data.error==0){
              console.log(123456)
              this.$toast('提交成功');
              this.$router.push({name:'index'})

            }else{
               this.$toast(response.data.msg);
            }
           
        })
    }
  },
  mounted() {
    // this.$islogin();
    // this.getlist();
  }
};
</script>

<style scoped>
.daigoubox{
  width: 100%;
  height: 100%;
  overflow: hidden;
}
.kuang{
  width: 100%;
  height: 120px;
  display: flex;
  align-items: center;
  font-size: 34px;
  padding: 0 20px;
  box-sizing: border-box;
  color: #404040;
}

.kuang input{
  margin-left: 20px;
  border: 2px solid #DDDDDD;
  width: 400px;
  border-radius: 8px;
  padding: 6px 20px;
  height: 60px;
  box-sizing: border-box;
  font-size: 26px;
}
.tijiao{
  width: 160px;
  height: 60px;
  text-align: center;
  line-height: 60px;
  color: #333;
  background: #F7F7F7;
  margin: auto;
  font-size: 34px;
  margin-top: 50px;
  margin-bottom: 20px;
  border: 2px solid #DDDDDD;
  border-radius: 8px;
}
</style>